home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / lisp / gcl-1.000 / gcl-1 / gcl-1.0 / h / object.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-07  |  22.6 KB  |  888 lines

  1. /*
  2.  Copyright (C) 1994 M. Hagiya, W. Schelter, T. Yuasa
  3.  
  4. This file is part of GNU Common Lisp, herein referred to as GCL
  5.  
  6. GCL is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU LIBRARY GENERAL PUBLIC LICENSE as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. GCL is distributed in the hope that it will be useful, but WITHOUT
  12. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public 
  14. License for more details.
  15.  
  16. You should have received a copy of the GNU Library General Public License 
  17. along with GCL; see the file COPYING.  If not, write to the Free Software
  18. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20. */
  21.  
  22. /*
  23.     object.h
  24. */
  25.  
  26. /*
  27.     Some system constants.
  28. */
  29.  
  30. #define    TRUE        1    /*  boolean true value  */
  31. #define    FALSE        0    /*  boolean false value  */
  32.  
  33. #ifdef SGC
  34. #define FIRSTWORD     short t;  char s,m
  35. #else
  36. #define FIRSTWORD     short t; short m
  37. #endif
  38.  
  39. #define    NBPP        4    /*  number of bytes per pointer  */
  40.  
  41. #ifndef PAGEWIDTH
  42. #define    PAGEWIDTH    11    /*  page width  */
  43. #endif
  44.                 /*  log2(PAGESIZE)  */
  45. #define    PAGESIZE    (1 << PAGEWIDTH)    /*  page size in bytes  */
  46.  
  47.  
  48. #define    CHCODELIM    256    /*  character code limit  */
  49.                 /*  ASCII character set  */
  50. #define    CHFONTLIM    1    /*  character font limit  */
  51. #define    CHBITSLIM    1    /*  character bits limit  */
  52. #define    CHCODEFLEN    8    /*  character code field length  */
  53. #define    CHFONTFLEN    0    /*  character font field length  */
  54. #define    CHBITSFLEN      0    /*  character bits field length  */
  55.  
  56. #define    PHTABSIZE    512    /*  number of entries  */
  57.                 /*  in the package hash table  */
  58.  
  59. #define    ARANKLIM    64    /*  array rank limit  */
  60.  
  61. #define    RTABSIZE    CHCODELIM
  62.                 /*  read table size  */
  63.  
  64. #define    CBMINSIZE    64    /*  contiguous block minimal size  */
  65.  
  66. #ifndef CHAR_SIZE
  67. #define CHAR_SIZE        8     /* number of bits in a char */
  68. #endif
  69.  
  70. typedef int bool;
  71. typedef int fixnum;
  72. typedef float shortfloat;
  73. typedef double longfloat;
  74. typedef unsigned short fatchar;
  75.  
  76.  
  77. #define SIGNED_CHAR(x) (((char ) -1) < (char )0 ? (char) x \
  78.           : (x >= (1<<(CHAR_SIZE-1)) ? \
  79.              x - (((int)(1<<(CHAR_SIZE-1))) << 1) \
  80.              : (char ) x))
  81.  
  82.  
  83. /*
  84.     Definition of the type of LISP objects.
  85. */
  86. typedef union lispunion *object;
  87.  
  88. typedef union int_object iobject;
  89. union int_object {object o; int i;};
  90.  
  91. /*
  92.     OBJect NULL value.
  93.     It should not coincide with any legal object value.
  94. */
  95. #define    OBJNULL        ((object)NULL)
  96.  
  97. /*
  98.     Definition of each implementation type.
  99. */
  100.  
  101. struct fixnum_struct {
  102.         FIRSTWORD;
  103.     fixnum    FIXVAL;        /*  fixnum value  */
  104. };
  105. #define    fix(obje)    (obje)->FIX.FIXVAL
  106.  
  107. #define    SMALL_FIXNUM_LIMIT    1024
  108.  
  109. struct fixnum_struct small_fixnum_table[2*SMALL_FIXNUM_LIMIT];
  110.  
  111. #define    small_fixnum(i)  \
  112.     (object)(small_fixnum_table+SMALL_FIXNUM_LIMIT+(i))
  113.  
  114. struct shortfloat_struct {
  115.             FIRSTWORD;
  116.     shortfloat    SFVAL;    /*  shortfloat value  */
  117. };
  118. #define    sf(obje)    (obje)->SF.SFVAL
  119.  
  120. struct longfloat_struct {
  121.             FIRSTWORD;
  122.     longfloat    LFVAL;    /*  longfloat value  */
  123. };
  124. #define    lf(obje)    (obje)->LF.LFVAL
  125.  
  126. struct bignum {
  127.             FIRSTWORD;
  128.     long             *big_self;    /*  bignum body  */
  129.     int        big_length;    /*  bignum length  */
  130. };
  131.  
  132. struct ratio {
  133.         FIRSTWORD;
  134.     object    rat_den;    /*  denominator  */
  135.                 /*  must be an integer  */
  136.     object    rat_num;    /*  numerator  */
  137.                 /*  must be an integer  */
  138. };
  139.  
  140. struct complex {
  141.         FIRSTWORD;
  142.     object    cmp_real;    /*  real part  */
  143.                 /*  must be a number  */
  144.     object    cmp_imag;    /*  imaginary part  */
  145.                 /*  must be a number  */
  146. };
  147.  
  148. struct character {
  149.             FIRSTWORD;
  150.     unsigned short    ch_code;    /*  code  */
  151.     unsigned char    ch_font;    /*  font  */
  152.     unsigned char    ch_bits;    /*  bits  */
  153. };
  154.  
  155. #ifdef MV
  156.  
  157. #endif
  158.  
  159. #ifdef AV
  160. struct character character_table1[256+128];
  161. #endif
  162. #define character_table (character_table1+128)
  163. #define    code_char(c)        (object)(character_table+(c))
  164. #define    char_code(obje)        (obje)->ch.ch_code
  165. #define    char_font(obje)        (obje)->ch.ch_font
  166. #define    char_bits(obje)        (obje)->ch.ch_bits
  167.  
  168. enum stype {            /*  symbol type  */
  169.     stp_ordinary,        /*  ordinary  */
  170.     stp_constant,        /*  constant  */
  171.         stp_special        /*  special  */
  172. };
  173.  
  174. #define    Cnil            ((object)&Cnil_body)
  175. #define    Ct            ((object)&Ct_body)
  176.  
  177. struct symbol {
  178.         FIRSTWORD;
  179.     object    s_dbind;    /*  dynamic binding  */
  180.     int    (*s_sfdef)();    /*  special form definition  */
  181.                 /*  This field coincides with c_car  */
  182.  
  183. #define    NOT_SPECIAL        ((int (*)())Cnil)
  184.  
  185. #define    s_fillp        st_fillp
  186. #define    s_self        st_self
  187.  
  188.     int    s_fillp;    /*  print name length  */
  189.     char    *s_self;    /*  print name  */
  190.                 /*  These fields coincide with  */
  191.                 /*  st_fillp and st_self.  */
  192.  
  193.     object    s_gfdef;        /*  global function definition  */
  194.                 /*  For a macro,  */
  195.                 /*  its expansion function  */
  196.                 /*  is to be stored.  */
  197.     object    s_plist;    /*  property list  */
  198.     object    s_hpack;    /*  home package  */
  199.                 /*  Cnil for uninterned symbols  */
  200.     short    s_stype;    /*  symbol type  */
  201.                 /*  of enum stype  */
  202.     short    s_mflag;    /*  macro flag  */
  203. };
  204.  
  205. struct symbol Cnil_body, Ct_body;
  206.  
  207. struct package {
  208.         FIRSTWORD;
  209.     object    p_name;        /*  package name  */
  210.                 /*  a string  */
  211.     object    p_nicknames;    /*  nicknames  */
  212.                 /*  list of strings  */
  213.     object    p_shadowings;    /*  shadowing symbol list  */
  214.     object    p_uselist;    /*  use-list of packages  */
  215.     object    p_usedbylist;    /*  used-by-list of packages  */
  216.     object    *p_internal;    /*  hashtable for internal symbols  */
  217.     object    *p_external;    /*  hashtable for external symbols  */
  218.     int p_internal_size;    /* size of internal hash table*/
  219.     int p_external_size;     /* size of external hash table */
  220.     int p_internal_fp;       /* [rough] number of symbols */
  221.         int p_external_fp;    /* [rough]  number of symbols */
  222.     struct package
  223.         *p_link;    /*  package link  */
  224. };
  225.  
  226. /*
  227.     The values returned by intern and find_symbol.
  228.     File_symbol may return 0.
  229. */
  230. #define    INTERNAL    1
  231. #define    EXTERNAL    2
  232. #define    INHERITED    3
  233.  
  234. /*
  235.     All the packages are linked through p_link.
  236. */
  237. struct package *pack_pointer;    /*  package pointer  */
  238.  
  239. struct cons {
  240.         FIRSTWORD;
  241.     object    c_cdr;        /*  cdr  */
  242.     object    c_car;        /*  car  */
  243. };
  244.  
  245. enum httest {            /*  hash table key test function  */
  246.     htt_eq,            /*  eq  */
  247.     htt_eql,        /*  eql  */
  248.     htt_equal        /*  equal  */
  249. };
  250.  
  251. struct htent {            /*  hash table entry  */
  252.     object    hte_key;    /*  key  */
  253.     object    hte_value;    /*  value  */
  254. };
  255.  
  256. struct hashtable {        /*  hash table header  */
  257.         FIRSTWORD;
  258.     struct htent
  259.         *ht_self;    /*  pointer to the hash table  */
  260.     object    ht_rhsize;    /*  rehash size  */
  261.     object    ht_rhthresh;    /*  rehash threshold  */
  262.     int    ht_nent;    /*  number of entries  */
  263.     int    ht_size;    /*  hash table size  */
  264.     short    ht_test;    /*  key test function  */
  265.                 /*  of enum httest  */
  266. };
  267.  
  268. enum aelttype {            /*  array element type  */
  269.     aet_object,        /*  t  */
  270.     aet_ch,            /*  string-char  */
  271.     aet_bit,        /*  bit  */
  272.     aet_fix,        /*  fixnum  */
  273.     aet_sf,            /*  short-float  */
  274.     aet_lf,            /*  long-float  */
  275.     aet_char,               /* signed char */
  276.         aet_uchar,               /* unsigned char */
  277.     aet_short,              /* signed short */
  278.     aet_ushort,             /*  unsigned short   */
  279.       };
  280.  
  281. struct array {            /*  array header  */
  282.         FIRSTWORD;
  283.     short    a_rank;        /*  array rank  */
  284. /*    short    v_hasfillp;        has-fill-pointer flag  */
  285.     short    a_adjustable;    /*  adjustable flag  */
  286.     int    a_dim;        /*  dimension  */
  287.     int    *a_dims;    /*  table of dimensions  */
  288. /*    int    v_fillp;        fill pointer  */
  289.     object    *a_self;    /*  pointer to the array  */
  290.     object    a_displaced;    /*  displaced  */
  291.     short    a_elttype;    /*  element type  */
  292.     short    a_offset;    /*  bitvector offset  */
  293. };
  294.  
  295.  
  296.  
  297. struct vector {            /*  vector header  */
  298.         FIRSTWORD;
  299.     short    v_hasfillp;    /*  has-fill-pointer flag  */
  300.     short    v_adjustable;    /*  adjustable flag  */
  301.     int    v_dim;        /*  dimension  */
  302.     int    v_fillp;    /*  fill pointer  */
  303.                 /*  For simple vectors,  */
  304.                 /*  v_fillp is equal to v_dim.  */
  305.     object    *v_self;    /*  pointer to the vector  */
  306.     object    v_displaced;    /*  displaced  */
  307.     short    v_elttype;    /*  element type  */
  308.     short    v_offset;    /*  not used  */
  309. };
  310.  
  311. struct string {            /*  string header  */
  312.         FIRSTWORD;
  313.     short    st_hasfillp;    /*  has-fill-pointer flag  */
  314.     short    st_adjustable;    /*  adjustable flag  */
  315.     int    st_dim;        /*  dimension  */
  316.                 /*  string length  */
  317.     int    st_fillp;    /*  fill pointer  */
  318.                 /*  For simple strings,  */
  319.                 /*  st_fillp is equal to st_dim.  */
  320.     char    *st_self;    /*  pointer to the string  */
  321.     object    st_displaced;    /*  displaced  */
  322. };
  323.  
  324. struct ustring {
  325.         FIRSTWORD;
  326.     short    ust_hasfillp;
  327.     short    ust_adjustable;
  328.     int    ust_dim;
  329.     int    ust_fillp;
  330.     unsigned char
  331.         *ust_self;
  332.     object    ust_displaced;
  333. };
  334.  
  335. #define USHORT(x,i) (((unsigned short *)(x)->ust.ust_self)[i])
  336.  
  337. struct bitvector {        /*  bitvector header  */
  338.         FIRSTWORD;
  339.     short    bv_hasfillp;    /*  has-fill-pointer flag  */
  340.     short    bv_adjustable;    /*  adjustable flag  */
  341.     int    bv_dim;        /*  dimension  */
  342.                 /*  number of bits  */
  343.     int    bv_fillp;    /*  fill pointer  */
  344.                 /*  For simple bitvectors,  */
  345.                 /*  st_fillp is equal to st_dim.  */
  346.     char    *bv_self;    /*  pointer to the bitvector  */
  347.     object    bv_displaced;    /*  displaced  */
  348.     short    bv_elttype;    /*  not used  */
  349.     short    bv_offset;    /*  bitvector offset  */
  350.                 /*  the position of the first bit  */
  351.                 /*  in the first byte  */
  352. };
  353.  
  354. struct fixarray {        /*  fixnum array header  */
  355.         FIRSTWORD;
  356.     short    fixa_rank;    /*  array rank  */
  357.     short    fixa_adjustable;/*  adjustable flag  */
  358.     int    fixa_dim;    /*  dimension  */
  359.     int    *fixa_dims;    /*  table of dimensions  */
  360.     fixnum    *fixa_self;    /*  pointer to the array  */
  361.     object    fixa_displaced;    /*  displaced  */
  362.     short    fixa_elttype;    /*  element type  */
  363.     short    fixa_offset;    /*  not used  */
  364. };
  365.  
  366. struct sfarray {        /*  short-float array header  */
  367.         FIRSTWORD;
  368.     short    sfa_rank;    /*  array rank  */
  369.     short    sfa_adjustable;    /*  adjustable flag  */
  370.     int    sfa_dim;    /*  dimension  */
  371.     int    *sfa_dims;    /*  table of dimensions  */
  372.     shortfloat
  373.         *sfa_self;    /*  pointer to the array  */
  374.     object    sfa_displaced;    /*  displaced  */
  375.     short    sfa_elttype;    /*  element type  */
  376.     short    sfa_offset;    /*  not used  */
  377. };
  378.  
  379. struct lfarray {        /*  long-float array header  */
  380.         FIRSTWORD;
  381.     short    lfa_rank;    /*  array rank  */
  382.     short    lfa_adjustable;    /*  adjustable flag  */
  383.     int    lfa_dim;        /*  dimension  */
  384.     int    *lfa_dims;    /*  table of dimensions  */
  385.     longfloat
  386.         *lfa_self;    /*  pointer to the array  */
  387.     object    lfa_displaced;    /*  displaced  */
  388.     short    lfa_elttype;    /*  element type  */
  389.     short    lfa_offset;    /*  not used  */
  390. };
  391.  
  392. struct structure {        /*  structure header  */
  393.         FIRSTWORD;
  394.     object    str_def;    /*  structure definition (a structure)  */
  395.     object    *str_self;    /*  structure self  */
  396. };
  397.  
  398. struct s_data {object name;
  399.            int length;
  400.            object raw;
  401.            object included;
  402.            object includes;
  403.            object staticp;
  404.            object print_function;
  405.            object slot_descriptions;
  406.            object slot_position;
  407.            int    size;
  408.            object has_holes;
  409.          };
  410.  
  411. #define S_DATA(x) ((struct s_data *)((x)->str.str_self))
  412. #define SLOT_TYPE(def,i) (((S_DATA(def))->raw->ust.ust_self[i]))
  413. #define SLOT_POS(def,i) USHORT(S_DATA(def)->slot_position,i)
  414. #define STREF(type,x,i) (*((type *)(((char *)((x)->str.str_self))+(i))))
  415.  
  416.  
  417.  
  418. enum smmode {            /*  stream mode  */
  419.     smm_input,        /*  input  */
  420.     smm_output,        /*  output  */
  421.     smm_io,            /*  input-output  */
  422.     smm_probe,        /*  probe  */
  423.     smm_synonym,        /*  synonym  */
  424.     smm_broadcast,        /*  broadcast  */
  425.     smm_concatenated,    /*  concatenated  */
  426.     smm_two_way,        /*  two way  */
  427.     smm_echo,        /*  echo  */
  428.     smm_string_input,    /*  string input  */
  429.     smm_string_output,    /*  string output  */
  430.     smm_user_defined        /*  for user defined */ 
  431. };
  432.  
  433. struct stream {
  434.         FIRSTWORD;
  435.     FILE    *sm_fp;        /*  file pointer  */
  436.     object    sm_object0;    /*  some object  */
  437.     object    sm_object1;    /*  some object */
  438.     int    sm_int0;    /*  some int  */
  439.     int    sm_int1;    /*  some int  */
  440.     char      *sm_buffer;     /*  ptr to BUFSIZE block of storage */
  441.     short    sm_mode;    /*  stream mode  */
  442.                 /*  of enum smmode  */
  443. };
  444.  
  445.  
  446. #ifdef BSD
  447. #ifdef SUN3
  448. #define    BASEFF        (unsigned char *)0xffffffff
  449. #else
  450. #define    BASEFF        (char *)0xffffffff
  451. #endif
  452. #endif
  453.  
  454. #ifdef ATT
  455. #define    BASEFF        (unsigned char *)0xffffffff
  456. #endif
  457.  
  458. #ifdef E15
  459. #define    BASEFF        (unsigned char *)0xffffffff
  460. #endif
  461.  
  462. #ifdef MV
  463.  
  464.  
  465. #endif
  466.  
  467. struct random {
  468.             FIRSTWORD;
  469.     unsigned    rnd_value;    /*  random state value  */
  470. };
  471.  
  472. enum chattrib {            /*  character attribute  */
  473.     cat_whitespace,        /*  whitespace  */
  474.     cat_terminating,    /*  terminating macro  */
  475.     cat_non_terminating,    /*  non-terminating macro  */
  476.     cat_single_escape,    /*  single-escape  */
  477.     cat_multiple_escape,    /*  multiple-escape  */
  478.     cat_constituent        /*  constituent  */
  479. };
  480.  
  481. struct rtent {                /*  read table entry  */
  482.     enum chattrib    rte_chattrib;    /*  character attribute  */
  483.     object        rte_macro;    /*  macro function  */
  484.     object        *rte_dtab;    /*  pointer to the  */
  485.                     /*  dispatch table  */
  486.                     /*  NULL for  */
  487.                     /*  non-dispatching  */
  488.                     /*  macro character, or  */
  489.                     /*  non-macro character  */
  490. };
  491.  
  492. struct readtable {            /*  read table  */
  493.             FIRSTWORD;
  494.     struct rtent    *rt_self;    /*  read table itself  */
  495. };
  496.  
  497. struct pathname {
  498.         FIRSTWORD;
  499.     object    pn_host;    /*  host  */
  500.     object    pn_device;    /*  device  */
  501.     object    pn_directory;    /*  directory  */
  502.     object    pn_name;    /*  name  */
  503.     object    pn_type;    /*  type  */
  504.     object    pn_version;    /*  version  */
  505. };
  506.  
  507. struct cfun {            /*  compiled function header  */
  508.         FIRSTWORD;
  509.     object    cf_name;    /*  compiled function name  */
  510.     int    (*cf_self)();    /*  entry address  */
  511.     object    cf_data;    /*  data the function uses  */
  512.                 /*  for GBC  */
  513. };
  514.  
  515. struct cclosure {        /*  compiled closure header  */
  516.         FIRSTWORD;
  517.     object    cc_name;    /*  compiled closure name  */
  518.     int    (*cc_self)();    /*  entry address  */
  519.     object    cc_env;        /*  environment  */
  520.     object    cc_data;    /*  data the closure uses  */
  521.                 /*  for GBC  */
  522.     object    *cc_turbo;    /*  turbo charger */
  523. };
  524. struct sfun {
  525.         FIRSTWORD; 
  526.     object    sfn_name;       /* name */
  527.     int    (*sfn_self)();  /* C start address of code */
  528.     object    sfn_data;       /* To object holding VV vector */
  529.     int sfn_argd;           /* description of args + number */
  530.  
  531.           };
  532. struct vfun {
  533.         FIRSTWORD; 
  534.     object    vfn_name;       /* name */
  535.     int    (*vfn_self)();  /* C start address of code */
  536.     object    vfn_data;       /* To object holding VV data */
  537.     unsigned short vfn_minargs; /* Min args and where varargs start */
  538.     unsigned short vfn_maxargs;    /* Max number of args */
  539.           };
  540. struct cfdata {
  541.      FIRSTWORD;
  542.      char *cfd_start;             /* beginning of contblock for fun */
  543.      int cfd_size;              /* size of contblock */
  544.      int cfd_fillp;             /* size of self */
  545.      object *cfd_self;          /* body */
  546.    };
  547. struct fat_string {            /*  vector header  */
  548.         FIRSTWORD;
  549.         unsigned fs_raw : 24;     /* tells if the things in leader are raw */
  550.     unsigned char fs_leader_length;     /* leader_Length  */
  551.     int    fs_dim;        /*  dimension  */
  552.     int    fs_fillp;    /*  fill pointer  */
  553.                 /*  For simple vectors,  */
  554.                 /*  fs_fillp is equal to fs_dim.  */
  555. #define fs_leader(ar,i) (((object *)((ar)->fs.fs_self))[-(i+1)])
  556.     fatchar     *fs_self;    /*  pointer to the vector
  557. Note the leader starts at (int *) *fs_self - fs_leader_length */
  558. };
  559.  
  560.  
  561. struct dclosure {        /*  compiled closure header  */
  562.         FIRSTWORD;
  563.     int    (*dc_self)();    /*  entry address  */
  564.     object    *dc_env;    /*  environment  */
  565. };
  566.  
  567.  
  568. struct spice {
  569.         FIRSTWORD;
  570.     int    spc_dummy;
  571. };
  572.  
  573. /*
  574.     dummy type
  575. */
  576. struct dummy {
  577.     FIRSTWORD;
  578. };
  579.  
  580. /*
  581.     Definition of lispunion.
  582. */
  583. union lispunion {
  584.     struct fixnum_struct
  585.             FIX;    /*  fixnum  */
  586.     struct bignum    big;    /*  bignum  */
  587.     struct ratio    rat;    /*  ratio  */
  588.     struct shortfloat_struct
  589.             SF;    /*  short floating-point number  */
  590.     struct longfloat_struct
  591.             LF;    /*  long floating-point number  */
  592.     struct complex    cmp;    /*  complex number  */
  593.     struct character
  594.             ch;    /*  character  */
  595.     struct symbol    s;    /*  symbol  */
  596.     struct package    p;    /*  package  */
  597.     struct cons    c;    /*  cons  */
  598.     struct hashtable
  599.             ht;    /*  hash table  */
  600.     struct array    a;    /*  array  */
  601.     struct fat_string fs; /* fat string fatchar 's */
  602.         struct dclosure dc;
  603.     struct vector    v;    /*  vector  */
  604.     struct string    st;    /*  string  */
  605.     struct ustring    ust;
  606.     struct bitvector
  607.             bv;    /*  bit-vector  */
  608.     struct structure
  609.             str;    /*  structure  */
  610.     struct stream    sm;    /*  stream  */
  611.     struct random    rnd;    /*  random-states  */
  612.     struct readtable
  613.             rt;    /*  read table  */
  614.     struct pathname    pn;    /*  path name  */
  615.     struct cfun    cf;    /*  compiled function  uses value stack] */
  616.     struct cclosure    cc;    /*  compiled closure  uses value stack */
  617.     struct sfun     sfn;    /*  simple function */
  618.     struct vfun     vfn;    /*  function with variable number of args */
  619.     struct cfdata   cfd;    /* compiled fun data */
  620.     struct spice    spc;    /*  spice  */
  621.  
  622.     struct dummy    d;    /*  dummy  */
  623.  
  624.     struct fixarray    fixa;    /*  fixnum array  */
  625.     struct sfarray    sfa;    /*  short-float array  */
  626.     struct lfarray    lfa;    /*  long-float array  */
  627. };
  628.  
  629. /*
  630.     The struct of free lists.
  631. */
  632. struct freelist {
  633.     FIRSTWORD;
  634.     object    f_link;
  635. };
  636.  
  637. #define    FREE    (-1)        /*  free object  */
  638.  
  639. /*
  640.     Implementation types.
  641. */
  642. enum type {
  643.     t_cons,
  644.     t_start = 0 , /* t_cons, */
  645.     t_fixnum,
  646.     t_bignum,
  647.     t_ratio,
  648.     t_shortfloat,
  649.     t_longfloat,
  650.     t_complex,
  651.     t_character,
  652.     t_symbol,
  653.     t_package,
  654. /*    t_cons,  */
  655.     t_hashtable,
  656.     t_array,
  657.     t_vector,
  658.     t_string,
  659.     t_bitvector,
  660.     t_structure,
  661.     t_stream,
  662.     t_random,
  663.     t_readtable,
  664.     t_pathname,
  665.     t_cfun,
  666.     t_cclosure,
  667.     t_sfun,
  668.         t_gfun,
  669.     t_vfun,
  670.     t_cfdata,
  671.     t_spice,
  672.     t_fat_string,
  673.         t_dclosure,
  674.    
  675.     t_end,
  676.     t_contiguous,        /*  contiguous block  */
  677.     t_relocatable,        /*  relocatable block  */
  678.     t_other            /*  other  */
  679. };
  680. /*
  681.     Type_of.
  682. */
  683. #define    type_of(obje)    ((enum type)(((object)(obje))->d.t))
  684.  
  685. /*
  686.     Storage manager for each type.
  687. */
  688. struct typemanager {
  689.     enum type
  690.         tm_type;    /*  type  */
  691.     short    tm_size;    /*  element size in bytes  */
  692.     short   tm_nppage;    /*  number per page  */
  693.     object    tm_free;    /*  free list  */
  694.                 /*  Note that it is of type object.  */
  695.     int    tm_nfree;    /*  number of free elements  */
  696.     int    tm_nused;    /*  number of elements used  */
  697.     int    tm_npage;    /*  number of pages  */
  698.     int    tm_maxpage;    /*  maximum number of pages  */
  699.     char    *tm_name;    /*  type name  */
  700.     int    tm_gbccount;    /*  GBC count  */
  701.     object  tm_alt_free;    /*  Alternate free list (swap with tm_free) */
  702.     int     tm_alt_nfree;   /*  Alternate nfree (length of nfree) */
  703.     short   tm_sgc;         /*  this type has at least this many
  704.                     sgc pages */
  705.     short   tm_sgc_minfree;   /* number free on a page to qualify for
  706.                     being an sgc page */
  707.     short   tm_sgc_max;     /* max on sgc pages */
  708.     short   tm_min_grow;    /* min amount to grow when growing */
  709.     short   tm_max_grow;    /* max amount to grow when growing */
  710.     short   tm_growth_percent;  /* percent to increase maxpages */
  711.  
  712. };
  713.  
  714. /*
  715.     The table of type managers.
  716. */
  717. struct typemanager tm_table[ 32  /* (int) t_relocatable */];
  718.  
  719. #define    tm_of(t)    (&(tm_table[(int)tm_table[(int)(t)].tm_type]))
  720.  
  721. /*
  722.     Contiguous block header.
  723. */
  724. struct contblock {        /*  contiguous block header  */
  725.     int    cb_size;    /*  size in bytes  */
  726.     struct contblock
  727.         *cb_link;    /*  contiguous block link  */
  728. };
  729.  
  730. /*
  731.     The pointer to the contiguous blocks.
  732. */
  733. struct contblock *cb_pointer;    /*  contblock pointer  */
  734.  
  735. /*
  736.     Variables for memory management.
  737. */
  738. int ncb;            /*  number of contblocks  */
  739. int ncbpage;            /*  number of contblock pages  */
  740. int maxcbpage;            /*  maximum number of contblock pages  */
  741. int cbgbccount;            /*  contblock gbc count  */
  742.  
  743. int holepage;            /*  hole pages  */
  744. int nrbpage;            /*  number of relblock pages  */
  745. int rbgbccount;            /*  relblock gbc count  */
  746.  
  747. char *rb_start;            /*  relblock start  */
  748. char *rb_end;            /*  relblock end  */
  749. char *rb_limit;            /*  relblock limit  */
  750. char *rb_pointer;        /*  relblock pointer  */
  751. char *rb_start1;        /*  relblock start in copy space  */
  752. char *rb_pointer1;        /*  relblock pointer in copy space  */
  753.  
  754. char *heap_end;            /*  heap end  */
  755. char *core_end;            /*  core end  */
  756.  
  757. char *tmp_alloc;
  758.  
  759. /* make f allocate enough extra, so that we can round
  760.    up, the address given to an even multiple.   Special
  761.    case of size == 0 , in which case we just want an aligned
  762.    number in the address range
  763.    */
  764.  
  765. #define ALLOC_ALIGNED(f, size,align) \
  766.   (align <= sizeof(long) ? (char *)((f)(size)) : \
  767.    (tmp_alloc = (char *)((f)(size+(size ?(align)-1 : 0)))+(align)-1 , \
  768.    (char *)(align * (((unsigned int)tmp_alloc)/align))))
  769. #define AR_ALLOC(f,n,type) (type *) \
  770.   (ALLOC_ALIGNED(f,(n)*sizeof(type),sizeof(type)))
  771.  
  772. #ifndef HOLEPAGE
  773. #define    HOLEPAGE    128
  774. #endif
  775.  
  776.  
  777. #define    INIT_HOLEPAGE    150
  778. #define    INIT_NRBPAGE    50
  779. #define    RB_GETA        512
  780.  
  781. /*
  782.     Endp macro.
  783. */
  784. /*
  785. #define    endp(obje)    ((enum type)((endp_temp = (obje))->d.t) == t_cons ? \
  786.              FALSE : endp_temp == Cnil ? TRUE : \
  787.              (bool)FEwrong_type_argument(Slist, endp_temp))
  788.  
  789. object endp_temp;
  790. */
  791.  
  792. #define    endp(obje)    endp1(obje)
  793.  
  794. #ifdef AV
  795. #define    STATIC    register
  796. #endif
  797. #ifdef MV
  798.  
  799. #endif
  800.  
  801. #define    TIME_ZONE    (-9)
  802.  
  803. int FIXtemp;
  804.  
  805. /*  For IEEEFLOAT, the double may have exponent in the second word
  806. (little endian) or first word.*/
  807.  
  808. #if defined(I386) || defined(LITTLE_ENDIAN)
  809. #define HIND 1  /* (int) of double where the exponent and most signif is */
  810. #define LIND 0  /* low part of a double */
  811. #else /* big endian */
  812. #define HIND 0
  813. #define LIND 1
  814. #endif
  815. #ifndef VOL
  816. #define VOL
  817. #endif
  818.  
  819.  
  820. #define    isUpper(xxx)    (((xxx)&0200) == 0 && isupper(xxx))
  821. #define    isLower(xxx)    (((xxx)&0200) == 0 && islower(xxx))
  822. #define    isDigit(xxx)    (((xxx)&0200) == 0 && isdigit(xxx))
  823. enum ftype {f_object,f_fixnum};
  824.  
  825. char *alloca_val;
  826. /*          ...xx|xx|xxxx|xxxx|   
  827.              ret  Narg     */
  828.  
  829. /*    a9a8a7a6a5a4a3a4a3a2a1a0rrrrnnnnnnnn
  830.          ai=argtype(i)         ret   nargs
  831.  */
  832. #define SFUN_NARGS(x) (x & 0xff) /* 8 bits */
  833. #define RESTYPE(x) (x<<8)   /* 3 bits */
  834.    /* set if the VFUN_NARGS = m ; has been set correctly */
  835. #define VFUN_NARG_BIT (1 <<11) 
  836. #define ARGTYPE(i,x) ((x) <<(12+(i*2)))
  837. #define ARGTYPE1(x)  (1 | ARGTYPE(0,x))
  838. #define ARGTYPE2(x,y) (2 | ARGTYPE(0,x)  | ARGTYPE(1,y))
  839. #define ARGTYPE3(x,y,z) (3 | ARGTYPE(0,x) | ARGTYPE(1,y) | ARGTYPE(2,z))
  840.  
  841. object make_si_sfun();
  842. object MVloc[10];
  843.  
  844. /* Set new to be an (object *) whose [i]'th elmt is the
  845.    ith elmnt in a va_list
  846.    MUST_COPY_VA_LIST should be true, if
  847.    ((vl[0] != va_arg(ap,object)) ||
  848.     (vl[1] != va_arg(ap,object)) || .. vl[n-1] != va_arg(ap,object))
  849.    Normal machines have va_list an ordinary array and a copy is unnecessary.
  850.  */
  851. #ifndef MUST_COPY_VA_LIST
  852. #define COERCE_VA_LIST(new,vl,n) new = (object *) (vl)
  853. #else
  854. #define COERCE_VA_LIST(new,vl,n) \
  855.  object Xxvl[65]; \
  856.  {int i; \
  857.   new=Xxvl; \
  858.   if (n >= 65) FEerror("Too long vl"); \
  859.   for (i=0 ; i < (n); i++) new[i]=va_arg(vl,object);}
  860. #endif
  861. #define make_si_vfun(s,f,min,max) \
  862.   make_si_vfun1(s,f,min | (max << 8))
  863.  
  864. /* Number of args supplied to a variable arg t_vfun
  865.  Used by the C function to set optionals */
  866.  
  867. struct call_data { object fun;
  868.            int argd;};
  869. struct call_data fcall;
  870. #define  VFUN_NARGS fcall.argd
  871.  
  872. /* we sometimes have to touch the header of arrays or structures
  873.    to make sure the page is writable */
  874. #ifdef SGC
  875. #define SGC_TOUCH(x) if ((x)->d.m) system_error(); (x)->d.m=0
  876. #else
  877. #define SGC_TOUCH(x)
  878. #endif
  879.  
  880. object funcall_cfun();
  881. object clear_compiler_properties();
  882. object siSlambda_block_expanded;
  883.  
  884. #ifndef FIX_PATH_STRING
  885. #define FIX_PATH_STRING(file) file
  886. #endif
  887.     
  888.